﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AccidentalNoise
{
    public class TranslatedDomain : ModuleBase
    {
        ScalarParameter tx, ty, tz;

        public TranslatedDomain(ModuleBase source, double tx, double ty, double tz)
        {
            this.Source = source;
            this.tx = new ScalarParameter(tx);
            this.ty = new ScalarParameter(ty);
            this.tz = new ScalarParameter(tz);
        }

        public TranslatedDomain(ModuleBase source, ModuleBase tx, ModuleBase ty, ModuleBase tz)
        {
            this.Source = source;
            this.tx = new ScalarParameter(tx);
            this.ty = new ScalarParameter(ty);
            this.tz = new ScalarParameter(tz);
        }

        public override double  Get(double x, double y)
        {
            double m_ax = tx == null ? 0 : tx.Get(x, y);
            double m_ay = ty == null ? 0 : ty.Get(x, y);

 	        return Source.Get(x + m_ax, y + m_ay);
        }

        public override double Get(double x, double y, double z)
        {
            double m_ax = tx == null ? 0 : tx.Get(x, y, z);
            double m_ay = ty == null ? 0 : ty.Get(x, y, z);
            double m_az = tz == null ? 0 : tz.Get(x, y, z);

            return Source.Get(x + m_ax, y + m_ay, z + m_az);
        }
    }
}
